#include <bits/stdc++.h>
using namespace std;
const int M = 2000010;
bool light[M];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    double a, t;
    cin >> a >> t;
    for (int j = 1; j <= t; j++) {
      int k = a * j;
      light[k] = !light[k];
    }
  }

  for (int i = 1; i < M; i++) {
    if (light[i]  ) {
      cout << i;
      break;
    }
  }

  return 0;
}